<template>
    <header class="dashboard-header">
        <h1 class="system-title">Python量化交易系统</h1>
        <nav class="nav-container">
            <ul class="nav-list">
                <li v-for="item in navItems" :key="item.label">
                    <RouterLink :to="item.path" v-slot="{ isActive }">
                        <span :class="['nav-link', { active: isActive }]">
                            {{ item.label }}
                        </span>
                    </RouterLink>
                </li>
            </ul>
        </nav>
    </header>
</template>

<script setup lang="ts" name="DashboardNavbar">
import { RouterLink } from 'vue-router';

// Props
interface Props {
    navItems?: Array<{
        label: string;
        path: string;
    }>;
}

const props = withDefaults(defineProps<Props>(), {
    navItems: () => [
        { label: '总览', path: '/' },
        { label: '数据统计', path: '/DataStatistics' },
    ]
});
</script>

<style scoped>
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eaeaea;
    position: relative;
}

.system-title {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.nav-container {
    display: flex;
    justify-content: center;
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.nav-list {
    display: flex;
    gap: 32px;
    margin: 0;
    padding: 0;
    list-style: none;
    pointer-events: auto;
}

:deep(.router-link-active),
:deep(.router-link-exact-active) {
    text-decoration: none !important;
    color: inherit !important;
}

.nav-link {
    color: #666;
    font-size: 15px;
    font-weight: 500;
    padding: 8px 12px;
    text-decoration: none;
    position: relative;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: inline-block;
}

.nav-link:hover {
    color: #2a62ff;
    background-color: rgba(42, 98, 255, 0.05);
}

.nav-link.active {
    color: #2a62ff;
    font-weight: 600;
    background-color: rgba(42, 98, 255, 0.05);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background-color: #2a62ff;
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 15px;
        margin-bottom: 15px;
        flex-direction: column;
    }

    .nav-container {
        position: static;
        width: 100%;
        margin-top: 12px;
    }

    .system-title {
        font-size: 18px;
    }

    .nav-list {
        gap: 20px;
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 8px 10px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .system-title {
        font-size: 16px;
        text-align: center;
    }

    .nav-list {
        gap: 15px;
    }

    .nav-link {
        font-size: 13px;
    }
}
</style>